#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int n, m, t[N], tr[N][26], fail[N], tag[N], idx, q[N], cnt[N], hh, tt;
char s[203][N];
bool tmp[N];
vector<int> vis[N];
int insert(char *s) {
	int u = 0;
	for(int i = 1; s[i]; i ++) {
		if(!tr[u][s[i] - 'a']) tr[u][s[i] - 'a'] = ++ idx;
		u = tr[u][s[i] - 'a'];
		cnt[u] ++;
	}
	return u;
}
void build() {
	hh = 0, tt = -1;
	for(int i = 0; i < 26; i ++)
		if(tr[0][i])
			q[++ tt] = tr[0][i];
	while(hh <= tt) {
		int u = q[hh ++];
		for(int i = 0; i < 26; i ++)
			if(tr[u][i]) {
				fail[tr[u][i]] = tr[fail[u]][i];
				q[++ tt] = tr[u][i];
			}
			else tr[u][i] = tr[fail[u]][i];
	}
}
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++) scanf("%s", s[i] + 1), t[i] = insert(s[i]);
	build();
	for(int i = tt; ~i; i --) cnt[fail[q[i]]] += cnt[q[i]];
	for(int i = 1; i <= n; i ++) printf("%d\n", cnt[t[i]]);
	return 0;
}